﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace whuc.PlaneGame
{
    /// <summary>
    /// 游戏对象  抽象类，不能够直接实例化
    /// </summary>
    public abstract class GameObject
    {
        public int X { get; set; }
        public int Y { get; set; }
        public Image img { get; set; }  //如果要使用图片，那么，需要导命名空间System.Drawing;
        public int Width { get; set; } //飞机的宽度与高度
        public int Height { get; set; }

        public GameObject(int x,int y,Image img)
        {
            this.X = x;
            this.Y = y;
            this.img = img;
            this.Width = this.img.Width;
            this.Height = this.img.Height;
        }

        /// <summary>
        /// 创建一个方法，把自己绘制在游戏界面上面
        /// </summary>
        /// <param name="g">gdi的画笔</param>
        public virtual void Draw(Graphics g)
        {
            g.DrawImage(this.img, this.X, this.Y, this.Width, this.Height);
        }


        /// <summary>
        /// 获取游戏对象矩形
        /// </summary>
        /// <returns>矩形</returns>
        public Rectangle getRectangle()
        {
            return new Rectangle(this.X, this.Y, this.Width, this.Height);
        }
    }
}

